//desc_race60

/*APDX A - Descriptive Table*/

global dir = "YourFilePath"
global output = "$dir"
global working_data = "$dir/ipums60_pub.dta"

cd "$output"
use "$working_data", clear

	
replace vetbin_60 = vetbin_60 * 100	
label var vetbin_60 "WWII Veteran (1960 Census)"

gen white = race_cat1 * 100
label var white "White"
	
gen black = race_cat2 * 100
label var black "Black"
	
gen noschool = educ_cat1 * 100 
label var noschool "No Schooling"
	
gen lths = educ_cat2 * 100
label var lths "Less than HS"
	
gen hs = educ_cat3 * 100
label var hs "High School"

gen mths = educ_cat4 * 100
label var mths "College"
	
gen employed = empstat_cat2 * 100
label var employed "Unemployed"

gen married = marst_cat1 * 100
label var married "Married"
	
gen met_ind = metrostat_cat1 * 100
label var met_ind "Metro Status Indeterminable"

gen met_otside = metrostat_cat2 * 100
label var met_otside "Not in Metro area"

gen met_urban = metrostat_cat3 * 100
label var met_urban "In metro central city"

gen met_suburb = metrostat_cat4 * 100
label var met_suburb "In metro outside of central city"

gen met_insideindet = metrostat_cat5 * 100
label var met_insideindet "In metro, status indeterminable"

replace ownbin = ownbin*100
label var ownbin "Owns Home"

replace inst_1927 = inst_1927*100
label var inst_1927 "Birth year 1917-1927"

replace hasch = hasch*100
replace migrant = migrant*100

label var age "Age"
label var inc_2018 "Income (2018 dollars)"
		
********************************************************************************	
* Appendix A: Descriptive Characteristics *
********************************************************************************	
putexcel set apdxA_desc.xls, replace 

putexcel A1 = ("Descriptive Characteristics of Sample by Race and Veteran Status (1912-1932 birth cohorts)") ///
	B2 = ("White") D2=("Black") ///
    B3= ("Non-veteran") C3=("Veteran") D3=("Non-veteran") E3=("Veteran") ///
    A46 = ("N") A47 = ("Source: 1% sample of 1960 IPUMS. Standard deviations in parenthesis.")

local controls "ownbin valueh_2018  inst_1927 vetbin_60 age migrant white black hasch noschool lths hs mths married  employed inc_2018 met_ind met_otside met_urban met_suburb met_insideindet"
di "`controls'"  
  
local row = 4  
foreach race in 1  2 {  // 1=White, 2=Black
    foreach vet in 0 100 {  // 0=Non-veteran, 100=Veteran
       local row = 4 
	   
	    local col = ""
        if (`race' == 1 & `vet' == 0) local col = "B"  
        if (`race' == 1 & `vet' == 100) local col = "C"  
        if (`race' == 2 & `vet' == 0) local col = "D"  
        if (`race' == 2 & `vet' == 100) local col = "E"  

        foreach k of local controls {
            local varlabel : var label `k' 
			
			sum `k' if race == `race' & vetbin_60 == `vet' 
			di "race == `race' & vetbin_60 =`vet'"
			local obs = string(`r(N)', "%12.0fc")
            local mean : di %4.1f r(mean) 
            local sd : di %4.1f r(sd) 

            putexcel A`row' = "`varlabel'"  
			
			putexcel `col'`row'=("`mean'") 	
            local row = `row' + 1

			putexcel `col'`row'=("(`sd')") 
            local row = `row' + 1
			
			putexcel `col'`row' = ("`obs'") 
			}
			}
			}


